// ===============================================================================
// scan: sequential scan of a large descriptor collection
// Created in September 2007 as a project for an Advanced Database Systems course
// (c) Reykjavik University, Björn Þór Jónsson, Kristleifur Daðason, Herwig Lejsek
// Contact author: Björn Þór Jónsson, Reykjavík University, bjorn@ru.is
// ===============================================================================

#ifndef QUERYDESCINFO
#define QUERYDESCINFO

#include <float.h>
#include <iostream>

#include "FlexDescriptor.h"

using namespace std;

class QueryDescInfo
{
public:
	QueryDescInfo(FlexDescriptor * _query, int _numDims, int _nns);
	~QueryDescInfo();

	// The query processing interface is very simple:
	void compareAndReplaceFarthest(FlexDescriptor *data);

	// The aggregation interface for getting ids is also simple
	void open();
	int *next();
	void close();

private:
	// The query information
	FlexDescriptor *query;
	int numDims;
	int nns;

	// Support for keeping track of scores
	int    neighbors;
	int   *identifiers;
	float *distances;
	
	// Support for efficient computation
	int farthest;
	void FindFarthest();
	float Distance(FlexDescriptor *data);

	// Support for aggregation
	int scanNext;
};

#endif

